import request from './api'

// 供应商端对账单API
const supplierBillingApi = {
  // 获取我的对账单列表
  getMyBillingList: (pageNum, pageSize, status) => {
    return request({
      url: '/supplier/billing/my-list',
      method: 'get',
      params: {
        pageNum,
        pageSize,
        status
      }
    })
  },
  
  // 获取对账单详情
  getBillingDetail: (id) => {
    return request({
      url: `/supplier/billing/my-detail/${id}`,
      method: 'get'
    })
  },
  
  // 确认对账单
  confirmBilling: (id) => {
    return request({
      url: `/supplier/billing/confirm/${id}`,
      method: 'post'
    })
  },
  
  // 提交对账单争议
  disputeBilling: (id, reason) => {
    return request({
      url: `/supplier/billing/dispute/${id}`,
      method: 'post',
      params: {
        reason
      }
    })
  },
  
  // 获取对账单明细
  getBillingItems: (statementId, pageNum, pageSize) => {
    return request({
      url: `/supplier/billing/my-items/${statementId}`,
      method: 'get',
      params: {
        pageNum,
        pageSize
      }
    })
  }
}

// 运营商端对账单API
const yunyingBillingApi = {
  // 生成对账单
  generateBilling: (data) => {
    return request({
      url: '/yunying/billing/generate',
      method: 'post',
      data
    })
  },
  
  // 批量生成对账单
  batchGenerateBillings: (data) => {
    return request({
      url: '/yunying/billing/batch-generate',
      method: 'post',
      data
    })
  },
  
  // 更新对账单状态
  updateBillingStatus: (data) => {
    return request({
      url: '/yunying/billing/update-status',
      method: 'post',
      data
    })
  },
  
  // 获取对账单详情
  getBillingDetail: (id) => {
    return request({
      url: `/yunying/billing/detail/${id}`,
      method: 'get'
    })
  },
  
  // 获取对账单列表
  getBillingList: (pageNum, pageSize, supplierId, status, startDate, endDate) => {
    return request({
      url: '/yunying/billing/list',
      method: 'get',
      params: {
        pageNum,
        pageSize,
        supplierId,
        status,
        startDate,
        endDate
      }
    })
  },
  
  // 获取对账单明细
  getBillingItems: (statementId, pageNum, pageSize) => {
    return request({
      url: `/yunying/billing/items/${statementId}`,
      method: 'get',
      params: {
        pageNum,
        pageSize
      }
    })
  }
}

export { supplierBillingApi, yunyingBillingApi }